#include <REGX52.H>
#include "Delayxms.h"

/**
  * @brief 获取独立键盘的键码,(范围0~4),无按键时返回0
  * @param 
  * @retval 无
  */
unsigned char Key(){
	unsigned char KeyNumber = 0;
	if (P3_1 == 0){Delayxms(20);while(P3_1 == 0);Delayxms(20);KeyNumber = 1;}
	if (P3_0 == 0){Delayxms(20);while(P3_0 == 0);Delayxms(20);KeyNumber = 2;}
	if (P3_2 == 0){Delayxms(20);while(P3_2 == 0);Delayxms(20);KeyNumber = 3;}
	if (P3_3 == 0){Delayxms(20);while(P3_3 == 0);Delayxms(20);KeyNumber = 4;}
	
	return KeyNumber;
}